package app.service.domain;

import com.google.common.collect.Lists;
import com.jfinal.aop.Aop;
import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.keter.framework.persist.base.BaseModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

public class Org extends BaseModel<Org> {
    /**
     * Logger for this class
     */
    private static final Logger logger = LoggerFactory.getLogger(Org.class);

    /*技术会员*/
    public final static String TYPE_TECHNICAL ="T";
    /*医疗会员*/
    public final static String TYPE_MEDICAL ="M";
    /*产业会员*/
    public final static String TYPE_INDUSTRY ="I";

    /*正常*/
    public final static String STATUS_NORMAL ="0";


    public static final Org dao = new Org();
//    public static final Org daox = Enhancer.enhance(Org.class);
    public static final Org daox = Aop.get(Org.class);

    @Override
    public List<Org> findAll() {
        List orgs = Lists.newArrayList();
        orgs.add(new Org());
        return orgs;
    }

    @Before(Tx.class)
    public void saveTx(Org org1, Org org2){
        org1.save();
        int i =  1/0;
        org2.save();
    }

    @Override
    public void validate() {
        validator()
        .notEmpty("status")
        .notEmpty("type")
        .notEmpty("email")
        .length("name", 1,40)
        ;
    }
}